﻿using System;
using System.Data.Objects;
using System.Linq;
using Repository;

namespace DataGenerator.DefaultSets
{
    /// <summary>
    /// Generator emplementation
    /// </summary>
    public class LocationSet : SetBase<Location>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="LocationSet"/> class.
        /// </summary>
        /// <param name="objectSet">The object set.</param>
        public LocationSet(ObjectSet<Location> objectSet)
            : base(objectSet)
        {
            Location1 = Location1;
            Location2 = Location2;
            Location3 = Location3;
            Location4 = Location4;
            Location5 = Location5;
            Location1.Description = "1st building.";
            Location1.Address = "Brovki 1";
            Location2.Description = "2st building.";
            Location2.Address = "Brovki 2";
            Location3.Description = "3st building.";
            Location3.Address = "Brovki 3";
            Location4.Description = "4st building.";
            Location4.Address = "Gikalo 1";
            Location5.Description = "5st building.";
            Location5.Address = "Gikalo 2";
        }

        public Location Location1
        {
            get { return Get(() => Location1); }
            set { Set(() => Location1, value); }
        }

        public Location Location2
        {
            get { return Get(() => Location2); }
            set { Set(() => Location2, value); }
        }

        public Location Location3
        {
            get { return Get(() => Location3); }
            set { Set(() => Location3, value); }
        }

        public Location Location4
        {
            get { return Get(() => Location4); }
            set { Set(() => Location4, value); }
        }

        public Location Location5
        {
            get { return Get(() => Location5); }
            set { Set(() => Location5, value); }
        }

        /// <summary>
        /// Searches the default value.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>Default entity.</returns>
        protected override Location SearchDefaultValue(string name)
        {
            return ObjectSet.FirstOrDefault(e => e.Name == name);
        }
    }
}
